home *** CD-ROM | disk | FTP | other *** search
- /*
- CDScsiID - An XCMD to open the .AppleCD driver for use by HyperCard.
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/10/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C -q2 CDScsiID.c
- link -sn Main=CDScsiID -sn STDIO=CDScsiID ∂
- -sn INTENV=CDScsiID -rt XFCN=42 ∂
- -m CDScsiID CDScsiID.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"CInterface.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
- #include <SysEqu.h>
-
- #define dRAMBased 0x20 /* bit 5 */
-
- /* prototype definitions for functions */
- OSErr GetScsiID(short, long *);
- Boolean IsItCD(short);
- OSErr StartAtTrack1(short);
- OSErr AStatus(short, short *);
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDScsiID
- *
- * Purpose: Open the driver and return the ioRefNum
- *
- * Returns: ioRefNum (used for subsequent calls to driver)
- *
- * Side Effects: none
- *
- * Description: We normally don't need any parameters. Extract the
- * vRefNum and pass it to a routine that finds the
- * equivalent SCSI ID. If we have an invalid vRefNum,
- * we return -1 as the SCSI ID, which is invalid.
- *
- ************************************************************************/
- pascal void
- CDScsiID(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Str31 returnString;
- OSErr result;
- short vRefNum;
- long bothRefNums;
- Handle refHandle;
- long scsiID;
-
- /* Must be no parameters */
- if ( paramPtr->paramCount != 0)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- bothRefNums = atoi(*(refHandle));
- DisposHandle(refHandle);
-
- vRefNum = bothRefNums >> 16;
-
- result = GetScsiID(vRefNum, &scsiID);
-
- NumToStr(paramPtr, scsiID, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
-
-
- /************************************************************************
- *
- * Function: GetScsiID
- *
- * Purpose: get volume reference number for audio CD
- *
- * Returns: OSErr
- * noErr if we found an audio volume
- * nsvErr if no such volume was mounted
- * (may return other errors if problem with system)
- *
- * Side Effects: fills in vRefNum
- *
- * Description: using the PBHGetVInfo call documented on pages IV-129
- * and IV-130 of IM v4, find the dRefNum. That's the
- * offset into the driver table of the driver, and also
- * the SCSI ID if you subtract 33.
- *
- * 0 is normally a valid vRefNum; it means "the system
- * volume." In this case, however, 0 means we haven't
- * done a CDOpen yet, or no one is online. We return
- * an error in this case.
- *
- ************************************************************************/
- OSErr
- GetScsiID(vRefNum, scsiID)
- short vRefNum; /* volume reference number of volume to use */
- long *scsiID; /* where to return scsi ID */
- {
- OSErr result;
- HVolumeParam hParamBlock;
-
- hParamBlock.ioCompletion = 0;
- hParamBlock.ioNamePtr = nil;
- hParamBlock.ioVRefNum = vRefNum;
- hParamBlock.ioVolIndex = 0;
- if (vRefNum == 0)
- result = -1; /* we don't accept 0 (system) as a valid CD */
- else
- result = PBHGetVInfo(&hParamBlock,false);
-
- if (result == noErr)
- *scsiID = (long)(-hParamBlock.ioVDRefNum) - 32L - 1L;
- else
- *scsiID = -1; /* an invalid scsiID. */
-
- return result;
- }
-
- #include <XCmdGlue.inc.c>
-